<template>
  <div>
    <button @click="changefn">按钮</button>

    <div>数量：{{ age }}</div>
  </div>
</template>
<script setup lang="ts"  name= "person555">
import {
  reactive,
  ref,
  toRefs,
  toRef,
  computed,
  watch,
  watchEffect,
} from "vue";
// 需求  当
let age = reactive({
  name: "张三",
  ages: 15,
});

let changefn = () => {
  age.ages = age.ages + 1;
};
//这个是watch升级本版watchEffect默认执行一次66,且很聪明 他能在判断里面if  默认去考虑你要监听什么,这个很智慧
// 其实用watchEffect去实现watch 你可省略很懂代码
watchEffect(() => {
  if (age.ages > 18) {
    console.log("成年啦");
  }
  console.log(66)
});
</script>